package com.mgblog.dao.imp;

import java.util.List;

import org.springframework.stereotype.Component;

import com.mgblog.dao.inter.ArticleSortDaoInter;
import com.mgblog.vo.ArticleSort;

/**
 * 
 * @author meigang 2014-11-26 16:11
 * 文章分类的DAO
 */
@Component("articleSortDao")
public class ArticleSortDao extends BaseDao implements ArticleSortDaoInter{
	/**
	 * 获得所有的文章分类
	 * @return
	 */
	public List<ArticleSort> getAllArticleSorts(String order) {
		// TODO Auto-generated method stub
		String hql = "from ArticleSort order by "+order;
		return executeQuery(hql, null);
	}

	@Override
	public boolean addArticleSort(ArticleSort articleSort) {
		// TODO Auto-generated method stub
		if(null != save(articleSort))
			return true;
		else
			return false;
	}

	@Override
	public ArticleSort getArticleSortById(int sortId) {
		// TODO Auto-generated method stub
		return (ArticleSort) findById(ArticleSort.class, sortId);
	}

	@Override
	public void addArticleNum(ArticleSort as) {
		// TODO Auto-generated method stub
		as.setArticleNum(as.getArticleNum()+1);
		update(as);
	}

}
